package cn.lianyutiantang.websocket.controller;



import cn.lianyutiantang.websocket.service.SysWebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *WebSocket服务器端推送
 * </p>
 *
 * @author zhengjl-WebSocket服务器端推送
 * @since 2018-09-27
 */
@RestController
@RequestMapping("/sysWebSocketServer")
public class SysWebSocketController {
    @Autowired
    SysWebSocketServer sysWebSocketServer;
    /**
     * 群发消息内容
     * @param message
     * @return
     */
    @RequestMapping("/sendAll")
    public Object sendAll(@RequestParam("message") String message){
        sysWebSocketServer.sendAll(message);
        return null;
    };


    /**
     * 指定会话ID发消息
     * @param message 消息内容
     * @param id 连接会话ID
     * @return
     */
    @RequestMapping("/sendOne")
    public Object sendOne(@RequestParam("message") String message, @RequestParam("id") String id){
        sysWebSocketServer.sendOne(message,id);
        return null;
    }

}
